package test.library;

import java.util.Scanner;

public class Main {
    public static int enter(){
        System.out.println("-------------------------");
        System.out.println("----------1.进入----------");
        System.out.println("----------2.退出----------");
        System.out.println("-------------------------");
        System.out.print("请输入:");
        Scanner scanner = new Scanner(System.in);
        int input = scanner.nextInt();
        if (input <= 2 && input >= 1){
            return input;
        }else{
            System.out.println("输入错误,请重新输入");
            enter();
            return 0;
        }
    }
    public static User login(){
        System.out.print("请输入你的姓名:");
        Scanner scanner = new Scanner(System.in);
        String name  = scanner.next();
        System.out.println("-------------------------");
        System.out.println("---------1.管理员---------");
        System.out.println("----------2.顾客----------");
        System.out.println("-------------------------");
        System.out.print("请选择你的身份:");
        int input = scanner.nextInt();
        if (input == 1){
            return new Manager(name);
        } else if (input == 2) {
            return new Customer(name);
        } else{
            System.out.println("输入错误,请重新输入");
            login();
            return null;
        }
    }
    public static void main(String[] ages){
        BookList bookList = new BookList();
        while(enter() == 1) {
            User user = login();
            int choice = user.menu() - 1;
            user.work(choice,bookList);
        }
        System.out.println("退出图书管理系统");
    }
}
